package com.szgr.baoyin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.szgr.baoyin.R;

import java.util.List;
import java.util.Map;

/**
 * Created by yang on 15/10/17.
 */
public class PersonalMessageListAdapter extends BaseAdapter {
    private Context mContext;
    private List<Map<String,Object>> data;
    public PersonalMessageListAdapter(Context context,List<Map<String,Object>> data){
        mContext = context;
        this.data = data;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_personal_list_view,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();
        Map<String, Object> map = data.get(position);
        holder.img_icon.setImageResource((int) map.get("icon"));
        holder.tv_name.setText((String)map.get("name"));
        return convertView;
    }

    class ViewHolder{
        ImageView img_icon;
        TextView tv_name;

        public ViewHolder(View view){
            img_icon = (ImageView) view.findViewById(R.id.personal_message_icon);
            tv_name = (TextView) view.findViewById(R.id.personal_message_name);
        }
    }
}
